package com.wkck.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wkck.domain.Delivered_Library;
import com.wkck.domain.Job;
import com.wkck.domain.JobAndJoin;
import com.wkck.domain.Resume;
import com.wkck.domain.PieChartInfoDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface JobMapper extends BaseMapper<Job> {

    /**
     * 职位详情简略信息
     */

    List<Job> getEasyMsg();

    /**
     * 得到职位详细信息
     */
    JobAndJoin getAll(Integer id);

    @Select("select * from resume where resume.user_id = #{id}")
    Resume getResumeByUserId(Integer id);

    @Insert("" +
            "insert into delivered_library(`job_join_id`,`user_id`,`resume_id`)" +
            " values(#{job_join_id},#{user_id},#{resume_id})" +
            "")
    int insertSendResumeMessage
            (
                    @Param("job_join_id") Integer job_join_id,
                    @Param("user_id") Integer user_id,
                    @Param("resume_id") Integer resume_id
            );

    @Select("select * from delivered_library where" +
            " job_join_id = #{job_join_id} and user_id = #{user_id} and resume_id = #{resume_id} ")
    Delivered_Library selectResumeAndCompany
            (
                    @Param("job_join_id") Integer job_join_id,
                    @Param("user_id") Integer user_id,
                    @Param("resume_id") Integer resume_id
            )
            ;

    /**
     * 查询用户数量，工作数量，公司数量，新闻数量
     * @return
     */

    @Select("select count(*) from (select * from job_join group by company) as test")
    Integer job_joinCount();

    @Select("SELECT COUNT(*) as value ,job_address as name from job GROUP BY job_address")
    List<PieChartInfoDto> getJobAddressInfo();

    /**
    * @Author: CK
    * @Date: 2023/12/22
    * @Param: `[career]`
    * @return:
    * @Description:
    */
    void insertCareer(Job job);

    @Select("select count(*) from job where job_status = '停止招聘';")
    Integer countJobLock();

    @Select("select job_address from job group by job_address")
    List<String> getCities();

    List<Job> getJobByIds(List<Integer> ids);
}
